package jm.nj.demo10mian.demo01;

import java.io.File;

/*
 * File类的判断功能
 * */
public class Demo04File {
    public static void main(String[] args) {
        method_1();
        //method_2();
    }

    /*
     * boolean exists()
     * 判断File 构造方法中封装路径是否存在
     * 存在就返回true,不存在就返回false
     * */
    private static void method_2() {
        File file = new File("d:\\bbb\\bb\\b.txt");
        boolean b = file.exists();
        System.out.println(b);

        file = new File("d:\\bbb\\b\\b.txt");
        b = file.exists();
        System.out.println(b);
    }

    /*
     *  boolean isDirectroy()
     * 判断File 构造方法封装路径是不是文件夹
     * 是true    否false
     * boolean isFile();
     * 判断构造方法中封装的路径是不是文件
     * */
    private static void method_1() {
        File file = new File("fifs");
        if (file.exists()) {
            boolean b1 = file.isFile();
            System.out.println("f:" + b1);

            boolean b2 = file.isDirectory();
            System.out.println("dir:" + b2);
        }

        file = new File("b.txt");
        if (file.exists()) {
            boolean b1 = file.isFile();
            System.out.println("f:" + b1);

            boolean b2 = file.isDirectory();
            System.out.println("dir:" + b2);
        }

    }


}
